package de.jmda.core.mproc;

import java.io.File;
import java.util.ArrayList;

import javax.annotation.processing.Processor;

/**
 * @author roger@jmda.de
 */
public abstract class LaunchConfigurationBuilder
{
	/**
	 * Builds <code>LaunchConfiguration</code> instance from <code>
	 * LaunchConfigurationBuilderData</code>.
	 *
	 * @param launchConfigurationBuilderData
	 * @return launch configuration
	 * @throws InstantiationException
	 * @throws IllegalAccessException
	 */
	public static LaunchConfiguration build(
			LaunchConfigurationBuilderData launchConfigurationBuilderData)
			throws InstantiationException, IllegalAccessException
	{
		LaunchConfiguration result = new LaunchConfiguration();
		
		result.files =
				new ArrayList<File>(
						launchConfigurationBuilderData.fileSetJavaSources
						                              .calculateFileSet());

		for (Class<? extends Processor> processorClass :
		     launchConfigurationBuilderData.processorClasses)
		{
			result.processors.add(processorClass.newInstance());
		}
		
		return result;
	}
}